#!/bin/sh

# This script can be used to upgrade/compile to the latest version
# Please note that all modifications on the original files are lost

echo "Updating to server revision..."
git fetch --all
git reset --hard origin/master

cmake -DCMAKE_BUILD_TYPE=Release .
if [ $? -ne 0 ]
then
		echo "CMake failed!";
		exit 1
fi
make
if [ $? -ne 0 ]
then
		echo "Compile failed!";
		exit 1
fi
# Restart domoticz
echo "Restarting Domoticz... (please standby...)"
sudo service domoticz.sh restart
